// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: SBZ3 Fall Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 72 : TYPE_SBZ3FALL


// Static Values

// Tables

event ObjectMain
	if object.state == 0
		if recAnimation != 0
			temp0 = recAnimation
		else
			temp0 = ANI_HURT
			temp0 <<= 16
			temp0 |= ANI_HURT
			temp0 <<= 8
		end if
		currentPlayer = 0
		while currentPlayer < playerCount
			CreateTempObject(TypeName[SBZ3 Fall], 0, object.xpos, object.ypos)
			object[tempObjectPos].state = 1
			object[tempObjectPos].value0 = currentPlayer
			object[tempObjectPos].direction = temp0
			object[tempObjectPos].direction &= 255
			temp0 >>= 8
			object[tempObjectPos].animation = temp0
			object[tempObjectPos].animation &= 255
			temp0 >>= 8
			currentPlayer++
		loop
		object.type = TypeName[Blank Object]
	else
		currentPlayer = object.value0
		if object[currentPlayer].gravity == GRAVITY_GROUND
			object.type = TypeName[Blank Object]
		else
			object[currentPlayer].direction = object.direction
			object[currentPlayer].animation = object.animation
			if object[currentPlayer].animation == ANI_JUMPING
				object[currentPlayer].state = PlayerObject_HandleAir
				object.type = TypeName[Blank Object]
			end if
			if object[currentPlayer].animation == ANI_FLYING
				object[currentPlayer].state = PlayerObject_HandleTailsFlight
				object[currentPlayer].value26 = 0x800
				object.type = TypeName[Blank Object]
			end if
			if object[currentPlayer].animation == ANI_GLIDING
				if object[currentPlayer].direction == FLIP_X
					object[currentPlayer].state = PlayerObject_KnuxGlideLeft
				else
					object[currentPlayer].state = PlayerObject_KnuxGlideRight
				end if
				object.type = TypeName[Blank Object]
			end if
			if object[currentPlayer].animation == ANI_GLIDING_DROP
				object[currentPlayer].state = PlayerObject_KnuxGlideDrop
				object.type = TypeName[Blank Object]
			end if
		end if
	end if
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
